home *** CD-ROM | disk | FTP | other *** search
- package koala.dynamicjava.classinfo;
-
- import java.util.Iterator;
- import java.util.List;
- import koala.dynamicjava.tree.FormalParameter;
- import koala.dynamicjava.tree.MethodDeclaration;
-
- public class TreeMethodInfo implements MethodInfo {
- private MethodDeclaration methodTree;
- private ClassFinder classFinder;
- private ClassInfo[] parameters;
- private ClassInfo[] exceptions;
- private ClassInfo declaringClass;
- private TypeVisitor typeVisitor;
-
- public MethodDeclaration getMethodDeclaration() {
- return this.methodTree;
- }
-
- public int getModifiers() {
- return this.methodTree.getAccessFlags();
- }
-
- public ClassInfo getReturnType() {
- return (ClassInfo)this.methodTree.getReturnType().acceptVisitor(this.typeVisitor);
- }
-
- public String getName() {
- return this.methodTree.getName();
- }
-
- public ClassInfo[] getParameterTypes() {
- if (this.parameters == null) {
- List var1 = this.methodTree.getParameters();
- Iterator var2 = var1.iterator();
- this.parameters = new ClassInfo[var1.size()];
-
- FormalParameter var4;
- for(int var3 = 0; var2.hasNext(); this.parameters[var3++] = (ClassInfo)var4.getType().acceptVisitor(this.typeVisitor)) {
- var4 = (FormalParameter)var2.next();
- }
- }
-
- return (ClassInfo[])this.parameters.clone();
- }
-
- public ClassInfo[] getExceptionTypes() {
- if (this.exceptions == null) {
- List var1 = this.methodTree.getExceptions();
- Iterator var2 = var1.iterator();
- this.exceptions = new ClassInfo[var1.size()];
-
- for(int var3 = 0; var2.hasNext(); this.exceptions[var3++] = this.lookupClass((String)var2.next(), this.declaringClass)) {
- }
- }
-
- return (ClassInfo[])this.exceptions.clone();
- }
-
- public boolean equals(Object var1) {
- return var1 != null && var1 instanceof TreeMethodInfo ? this.methodTree.equals(((TreeMethodInfo)var1).methodTree) : false;
- }
-
- protected ClassInfo lookupClass(String var1, ClassInfo var2) {
- try {
- return var2 == null ? this.classFinder.lookupClass(var1, var2) : this.classFinder.lookupClass(var1);
- } catch (ClassNotFoundException var4) {
- throw new NoClassDefFoundError(var4.getMessage());
- }
- }
-
- public TreeMethodInfo(MethodDeclaration var1, ClassFinder var2, ClassInfo var3) {
- this.methodTree = var1;
- this.classFinder = var2;
- this.declaringClass = var3;
- this.typeVisitor = new TypeVisitor(this.classFinder, this.declaringClass);
- }
- }
-